package com.chinawlx.wlxteacher.widget;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.chinawlx.wlxteacher.R;

/**
 * 作者:黄帅
 * 时间:16/9/10
 * 描述:班级调课加课
 */
public class WLXChooseLessonView extends FrameLayout {

    private TextView mTop;//上面一个text
    private TextView mBottom;//下面一个text
    private View mChooseView;

    public WLXChooseLessonView(Context context) {
        super(context);
        initView(context);
    }

    public WLXChooseLessonView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    //初始化布局
    private void initView(Context context) {
        mChooseView = LayoutInflater.from(context).inflate(R.layout.choose_lesson_view, null);
        mTop = (TextView) mChooseView.findViewById(R.id.top);
        mBottom = (TextView) mChooseView.findViewById(R.id.bottom);
        this.addView(mChooseView);
    }

    /**
     * 设置上面的文字
     * @param text
     */
    public void setTop(String text){
        mTop.setText(text+"");
    }

    /**
     * 设置下面的文字
     * @param text
     */
    public void setBottom(String text){
        mBottom.setText(text+"");
    }


    /**
     * 选择模式
     * @param mode
     */
    public void changeMode(ChooseMode mode) {
        switch (mode) {
            case GRAY:
                mChooseView.setBackgroundResource(R.drawable.shape_choose_lesson_gray);
                mTop.setTextColor(Color.GRAY);
                mBottom.setTextColor(Color.GRAY);
                break;
            case YELLOWRING:
                mChooseView.setBackgroundResource(R.drawable.shape_choose_lesson_ring);
                mTop.setTextColor(Color.BLACK);
                mBottom.setTextColor(Color.BLACK);
                break;
            case YELLOWROUND:
                mChooseView.setBackgroundResource(R.drawable.shape_choose_lesson_yellow);
                mTop.setTextColor(Color.BLACK);
                mBottom.setTextColor(Color.BLACK);
                break;
        }
    }
    /**
     * 布局类型:
     * 1.灰色圆环,灰色文字
     * 2.黄色圆环,黑色文字
     * 3.黄色圆,黑色文字
     */
    public enum ChooseMode {
        GRAY,
        YELLOWRING,
        YELLOWROUND
    }
}
